#ifndef CUTTER_HPP
#define CUTTER_HPP
#include <vector>

#include <Inventor/nodes/SoSeparator.h>
#include <Inventor/nodes/SoCylinder.h>
#include <Inventor/nodes/SoMatrixTransform.h>

#include "dexel.hpp"

#include "position_solutions.h"

using std::vector;


class cutter 
{
public:

  virtual ~cutter(){}
  
  
  virtual double xmin()=0;
  virtual double xmax()=0;

  virtual double ymin()=0;
  virtual double ymax()=0;

  virtual double zmin()=0;
  virtual double zmax()=0;

  virtual  SoSeparator* getview()=0;
  
  virtual interval intersect_z(double x0, double y0)=0;
};

class cylinder_cutter : public cutter
{
public:
  cylinder_cutter(double diam, double length, double z_bottom);
  cylinder_cutter()
  {
  }
  
  /*
    void set_diam(double);
    void set_length(double);
    void set_z_bottom(double);
  */
  virtual void set_orient(matr);
    
  virtual double xmin(){return min_bbox_ind(0);}
  virtual double xmax(){return max_bbox_ind(0);}

  virtual double ymin(){return min_bbox_ind(1);}
  virtual double ymax(){return max_bbox_ind(1);}
  
  virtual double zmin(){return min_bbox_ind(2);}
  virtual double zmax(){return max_bbox_ind(2);}

  virtual interval intersect_z(double x0, double y0);

  SoSeparator* getview();
  
  
  //private:

  double r, ztop, zbot ;
    
  matr orient;
  matr inverse_orient;

  void calc_bbox();
  void calc_i_bbox();

  double max_bbox_ind(int ind);
  double min_bbox_ind(int ind);

  SoSeparator* cyl;

  SoMatrixTransform *trans;
  
  
  
  vector<uvector> identity_bbox,bbox;
};

class vertical_cylinder: public cylinder_cutter
{
public:
  vertical_cylinder(double diam, double length, double z_bottom);
  void set_orient(matr);
    
   double xmin(){return xc-r;}
  double xmax(){return xc+r;}

   double ymin(){return yc-r;}
   double ymax(){return yc+r;}
  
   double zmin(){return zc+zbot;}
   double zmax(){return zc+ztop;}

   interval intersect_z(double x0, double y0);

  // SoSeparator* getview();
  double xc,yc,zc;
  
};

  

  
  
#endif
